﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using RemoteImaging.LicensePlate;

namespace RemoteImaging.Test
{
    [TestFixture]
    public class LicensePlateInfoTest
    {
        [Test]
        public void SaveTest()
        {
            //
            // TODO: Add test logic here
            //

            var l = new LicensePlate.LicensePlateInfo();
            l.CaptureTime = DateTime.Now;
            l.Image = TestDataProvider.Data.GetFrame().ToBitmap();
            l.LicensePlateNumber = "9876";

            Assert.IsFalse(l.ImageFileExists);
            Assert.IsNull(l.AbsoluteImagePath);
            l.Save();

            Assert.IsTrue(l.ImageFileExists);
            Assert.IsNotNull(l.AbsoluteImagePath);

            var suspect = new LicensePlate.ReportedCarInfo();
            suspect.LicenseNumber = "12345";

            var alerm = new SuspeciousCarAlermInfo();
            alerm.CapturedLicenseInfo = l;
            alerm.ReportedCarInfo = suspect;

            alerm.Save();

            var q = new XPQuery<SuspeciousCarAlermInfo>(Session.DefaultSession);
            var list = (from a in q select a).ToList();

            Assert.IsTrue(list.Count > 1);
            
            

        }
    }
}
